package kr.ac.kongju.gedl.main.web;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import kr.ac.kongju.gedl.board.service.BoardContentsService;
import kr.ac.kongju.gedl.board.vo.ContentsVO;
import kr.ac.kongju.gedl.cmmn.web.CU;
import kr.ac.kongju.gedl.code.service.CodeService;
import kr.ac.kongju.gedl.code.vo.CodeInfoVO;
import kr.ac.kongju.gedl.common.util.DateUtil;
import kr.ac.kongju.gedl.common.util.ListResultVO;
import kr.ac.kongju.gedl.item.vo.ItemLevelVO;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.support.SessionStatus;

import egovframework.rte.fdl.property.EgovPropertyService;

@Controller
public class MainController {
	
	/** EgovPropertyService */
    @Resource(name = "propertiesService")
    protected EgovPropertyService propertiesService;
    
    
    @Resource(name = "codeService")
    protected CodeService codeService;
    
    @Resource(name = "reportService")
    protected BoardContentsService boardContentsService;
    
    
    private static final String DEFAULT_SORT = "error_report_id";
    private static final String DEFAULT_DIR = "desc";
    
	
	
	@RequestMapping(value="/index.do")
	public String selectMobileMain(@ModelAttribute("searchVO") ContentsVO searchVO, 
    		ModelMap model, SessionStatus status,
			HttpSession session) throws Exception {
		
		List<CodeInfoVO> regionList = CU.getInstance().getCodeList("REGION");
		
		
		searchVO.setRowPerPage(3);
		searchVO.setBoardId(1);
		ListResultVO<ContentsVO> visualList1 = boardContentsService.retrieveListBoardContents(searchVO);
		
		searchVO.setRowPerPage(5);
		searchVO.setBoardId(2);
		ListResultVO<ContentsVO> visualList2 = boardContentsService.retrieveListBoardContents(searchVO);
		
		searchVO.setRowPerPage(5);
		searchVO.setBoardId(3);
		ListResultVO<ContentsVO> noticeList = boardContentsService.retrieveListBoardContents(searchVO);
		
		
		model.addAttribute("regionList", regionList);
		
		model.addAttribute("visualList1", visualList1);
		model.addAttribute("visualList2", visualList2);
		model.addAttribute("noticeList", noticeList);
		
		return "/main/index";
	}
	
	
}
